/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.haw.dbp.a4.gui;

import dc.connectionmanager.database.DBConnectionManager;
import dc.connectionmanager.logic.ICallback;
import de.haw.dbp.a4.logic.DBCommand;
import java.awt.event.MouseEvent;

/**
 *
 * @author jmenzel
 */
public class JPShowAusleihe extends ADBListPanel
{    
    public JPShowAusleihe(MainFrame rParent, DBConnectionManager cDB)
    {
        super(rParent, cDB);
        
        this.l_addItem.setVisible(false);
        this.l_addItem.setEnabled(false);
        
        this.cb_filter2.addItem("Kein Filter");
        this.cb_filter2.addItem("Mit Firma");
        this.cb_filter2.addItem("Ohne Firma");
    }

    @Override
    public void loadDefaultData(ICallback cb) 
    {
        ((DBCommand)this.dbcm.getCommandClass()).getAllAusleihe(cb);
    }

    @Override
    protected void loadDataWithFilter(ICallback cb)
    {
        int f1 = cb_filter.getSelectedIndex();
        int f2 = cb_filter2.getSelectedIndex();
        String qs = this.jtf_quicksearch.getText();
        
        if(f1 > 0 && f2 == 0)
        {
            ((DBCommand)this.dbcm.getCommandClass()).getAusleiheByMediumNameAndMTyp(cb, qs, ""+f1);
        }
        else if(f1 > 0 && f2 == 1)
        {
            ((DBCommand)this.dbcm.getCommandClass()).getAusleiheByMediumNameAndMTypWithFirma(cb, qs, ""+f1);
        }
        else if(f1 > 0 && f2 == 2)
        {
            ((DBCommand)this.dbcm.getCommandClass()).getAusleiheByMediumNameAndMTypWithoutFirma(cb, qs, ""+f1);
        }
        else if(f1 == 0 && f2 == 1)
        {
            ((DBCommand)this.dbcm.getCommandClass()).getAusleiheByMediumNameWithFirma(cb, qs);
        }
        else if(f1 == 0 && f2 == 2)
        {
            ((DBCommand)this.dbcm.getCommandClass()).getAusleiheByMediumNameWithoutFirma(cb, qs);
        }
        else
        {
            ((DBCommand)this.dbcm.getCommandClass()).getAusleiheByMediumName(cb, qs);
        }
    }

    @Override
    protected void loadFilterCombobox(ICallback cb)
    {
        ((DBCommand)this.dbcm.getCommandClass()).getAllMedienTyp(cb);
    }

    @Override
    protected void l_addItemOnClick(MouseEvent evt)
    {
        //Nothing to do here
    }
    
}
